package com.anonymous.community.ui.base;

import androidx.fragment.app.Fragment;
import com.tencent.bugly.crashreport.CrashReport;

public abstract class BaseFragment extends Fragment {

    @Override
    public void onResume() {
        super.onResume();
        // 页面进入统计
        String pageName = getPageName();
        if (pageName != null && !pageName.isEmpty()) {
            CrashReport.postCatchedException(new Exception("Page Enter: " + pageName));
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        // 页面退出统计
        String pageName = getPageName();
        if (pageName != null && !pageName.isEmpty()) {
            CrashReport.postCatchedException(new Exception("Page Exit: " + pageName));
        }
    }

    /**
     * 获取页面名称，子类需要重写此方法
     * @return 页面名称
     */
    protected abstract String getPageName();
}